using _RobotInspection.DTO;
using _RobotInspection.Entities;
using _RobotInspection.Interfaces;
using _RobotInspection.Models;
using _RobotInspection.ReApiHelp;
using _RobotInspection.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace _RobotInspection.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class QueryController : Controller
    {
        private readonly IUserService _service;
        private readonly ISqlSugarClient _db;
        private readonly ILogger<QueryController> _logger;

        public QueryController(ISqlSugarClient db, IUserService service, ILogger<QueryController> logger)
        {
            _service = service;
            _db = db;
            _logger = logger;
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="userPassword"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<ApiResponse<UserDto>>> Login(string userName, string userPassword)
        {
            var result = await _service.LoginAsync(userName, userPassword);
            return new OkObjectResult(result);
        }

        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="queryDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<ApiResponse<UserDto>>> Register([FromQuery] UserInsertDto queryDto)
        {
            var result = await _service.RegisterAsync(queryDto);
            return new OkObjectResult(result);
        }

        
        /*
        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<ApiResponse<List<DataManagement>>>> SelectData(SelectData selectData)
        {
            return await _service.SelectData(selectData);
        }
        
        /// <summary>
        /// 查询设备名称
        /// </summary>
        /// <param name="Unit">机组名称</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<ApiResponse<object>>> UnitSelect(string Unit)
        {
            return await _service.UnitSelect(Unit);
        }
        

        /// <summary>
        /// 查询数据项
        /// </summary>
        /// <param name="Unit">机组</param>
        /// <param name="equipName">设备名称</param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ActionResult<ApiResponse<object>>>EquipmentName(string Unit, string equipName)
        {
            return await _service.EquipmentName(Unit, equipName);
        }
        */

    }
}